<?php
/**
 * Magento Enterprise Edition
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Magento Enterprise Edition End User License Agreement
 * that is bundled with this package in the file LICENSE_EE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.magento.com/license/enterprise-edition
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magento.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magento.com for more information.
 *
 * @category    design
 * @package     enterprise_default
 * @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
 * @license http://www.magento.com/license/enterprise-edition
 */
?>
<?php
/**
 * @see Enterprise_GiftCardAccount_Block_Account_Redeem
 */
?>
<div class="page-title">
    <h1><?php echo Mage::helper('enterprise_giftcardaccount')->__('Gift Card'); ?></h1>
</div>
<div class="giftcardaccount">
    <span id="gc-please-wait" class="please-wait" style="display:none;">
        <img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" alt="" class="v-middle" /> <?php echo $this->__('Please wait, loading...') ?>
    </span>
    <?php echo $this->getMessagesBlock()->toHtml() ?>
    <form id="giftcard-form" action="<?php echo $this->getRedeemActionUrl() ?>" method="post"<?php if (!$this->canRedeem()): ?> onsubmit="giftCardAccountLookupBalance(); return false;"<?php endif; ?>>
        <div id="giftcard_balance_lookup"></div>
        <div class="fieldset">
            <ul class="form-list">
                <li>
                    <label for="giftcard_code"><?php echo $this->__('Enter gift card code') ?></label>
                    <div class="input-box">
                        <input class="required-entry input-text" id="giftcard_code" name="giftcard_code" value="<?php echo $this->getCurrentGiftcard(); ?>" />
                    </div>
                </li>
            </ul>
        </div>
        <div class="buttons-set form-buttons btn-only">
<?php if ($this->canRedeem()): ?>
            <button class="button" onclick="giftcardForm.submit()" type="button" value="<?php echo Mage::helper('core')->quoteEscape($this->__('Redeem Gift Card')) ?>"><span><span><?php echo $this->__('Redeem Gift Card') ?></span></span></button>
<?php endif; ?>
            <button class="button check-gc-status" id="gca_balance_button" type="button" value="<?php echo Mage::helper('core')->quoteEscape($this->__('Check status and balance')) ?>"><span><span><?php echo $this->__('Check status and balance') ?></span></span></button>
        </div>
    </form>
    <script type="text/javascript">
    //<![CDATA[
    var giftcardForm = new VarienForm('giftcard-form');
    function giftCardAccountLookupBalance() {
        if (giftcardForm.validator && !giftcardForm.validator.validate()) {
            return false;
        }
        new Ajax.Updater('giftcard_balance_lookup', '<?php echo Mage::getUrl('enterprise_giftcardaccount/cart/quickCheck', array('_secure' => true)) ?>', {
            onCreate: function() {
                $('gc-please-wait').show()
            },
            onComplete: function() {
                $('gc-please-wait').hide();
                if ($$('.col-main .messages')) {
                    $$('.col-main .messages').invoke('hide');
                }
            },
            parameters : {giftcard_code : $('giftcard_code').value}
        });
    }
    $('gca_balance_button').observe('click', giftCardAccountLookupBalance);
    //]]>
    </script>
</div>
